﻿<extend name="./_base"/>
<block name="css">

</block>
<block name="content">

        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span
                class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r"
                                                       style="line-height:1.6em;margin-top:3px"
                                                       href="javascript:location.reload();" title="刷新"><i
                class="Hui-iconfont">&#xe68f;</i></a></nav>
        <div class="page-container">
            <div class="text-c">
                <form class="Huiform" method="post" action="" target="_self">
                    <input type="text" class="input-text" style="width:250px" placeholder="输入管理员名称" name="search">
                    <button type="submit" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
                </form>
            </div>
            <div class="cl pd-5 bg-1 bk-gray mt-20 mb-20"><span class="l"><a href="javascript:;" onclick="datadel()"
                                                                       class="btn btn-danger radius"><i
                    class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a
                    href="javascript:;" onclick="add()"
                    class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a></span></div>
            <table id="admin-list" class="table table-border table-bordered table-bg">
                <thead>
                <tr>
                    <th scope="col" colspan="9">员工列表</th>
                </tr>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" name="" value=""></th>
                    <th width="40">ID</th>
                    <th width="150">登录名</th>
                    <th width="90">手机</th>
                    <th width="150">邮箱</th>
                    <th width="150">权限组</th>
                    <th width="130">添加时间</th>
                    <th width="100">是否已启用</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
            </table>
        </div>
</block>

<block name="script">
    <script src="__PUBLIC__/Lib/datatables/js/jquery.dataTables.js"></script>
    <script>
        scope.status_url='{:U(adminStatus)}';
        $('#admin-list').dataTable({
            order: [[1, 'desc']],
            processing: true,
            serverSide: true,
            ajax: {
                url: ''
            },
            columns: [
                {
                    data: 'id',
                    render: function (data) {
                        return '<input type="checkbox" name="id" value="' + data + '">'
                    },
                    className: 'text-c',
                    orderable: false
                },
                {
                    data: 'id',
                    className: 'text-c'
                },
                {data: 'username'},
                {data: 'phone'},
                {data: 'email'},
                {data: 'group',
                orderable:false
                },
                {data: 'create_time'},
                {
                    data: 'status',
                    render: function (data, type, row, meta) {
                        var render;
                        switch (parseInt(data)) {
                            case 0:
                                render = '<label class="label radius">已禁用</label>';
                                break;
                            case 1:
                                render = '<label class="label label-success radius">已启用</label>';
                                break;
                            default:
                                render = '<label class="label label-danger radius">未知状态</label>';
                                break;
                        }
                        return render;
                    },
                    className: 'text-c'
                },
                {
                    render: function (data, type, row, meta) {
                        var render;
                        switch (parseInt(row.status)) {
                            case -1:
                                render = '<a href="javascript:void(0);" onclick="start(' + row.id + ')" title="启用"><i class="Hui-iconfont Hui-iconfont-shangjia"></i></a>';
                                break;
                            case 0:
                                render = '<a href="javascript:void(0);" onclick="start(' + row.id + ')" title="启用"><i class="Hui-iconfont Hui-iconfont-shangjia"></i></a>';
                                render += '<a class="ml-5" href="javascript:void(0);" onclick="remove(' + row.id + ')" title="删除"><i class="Hui-iconfont Hui-iconfont-del3"></i></a>';
                                break;
                            case 1:
                                render = '<a href="javascript:void(0);" onclick="stop(' + row.id + ')" title="停用"><i class="Hui-iconfont Hui-iconfont-xiajia"></i></a>';
                                break;
                        }

                        render += '<a class="ml-5" href="javascript:void(0);" onclick="edit(' + row.id + ')" title="修改信息"><i class="Hui-iconfont Hui-iconfont-edit"></i></a>';
                        render += '<a class="ml-5" href="javascript:void(0);" onclick="show_log(' + row.id + ')" title="查看操作日志"><i class="Hui-iconfont Hui-iconfont-log"></i></a>';
                        return render;

                    },
                    "orderable": false,
                    "className": "text-c"
                }
            ]

        });

        function remove (id) {
            status(id, 'remove')
        }
        //启用
        function start(id) {
            status(id, 'start')
        }
        //停用
        function stop(id) {
            status(id, 'stop')
        }


        /*管理员-增加*/
        function add() {
            layer_show("新增管理员", '{:U(adminEdit)}' , 600, 600);
        }
        /*管理员-编辑*/
        function edit($id) {
            layer_show("修改管理员", '{:U(adminEdit)}?id='+$id , 600, 600);
        }

    </script>
</block>



